import Vue from 'vue';
import vuex from 'vuex';

Vue.use(vuex);

export default new vuex.Store({
  state: {
    PICKER_OPTIONS: {
      shortcuts: [{
          text: '最近一周',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
            picker.$emit('pick', [start, end]);
          }
        },
        {
          text: '最近一个月',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
            picker.$emit('pick', [start, end]);
          }
        },
        {
          text: '最近三个月',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
            picker.$emit('pick', [start, end]);
          }
        }
      ]
    },
    COLLAPSE: false,
    // 缓存组件
    KEEP_ALIVE_ROUTER: [
      "toutiao-currency-detail",
      "cpa-data-report",
      "cpa-data-refresh",
      "cpa-data-grab",
      "cpa-data-business",
      "cpa-customer-info",
      "cpa-customer-pro",
      "cpa-channel-info",
      "cpa-channel-pro",
      "cpa-product-name",
      "cpa-account-customers",
      "cpa-account-channels",
      "cpa-account-customer",
      "cpa-account-channel",
      "cpa-final-customer-month",
      "cpa-final-customer-receivable",
      "cpa-final-channel-month",
      "cpa-final-channel-pay",
      "cpa-final-receivable",
      "cpa-final-pay",
      "contract-contract-customer",
      "contract-contract-channel",
      "flow-customer",
      "flow-customer-aptitude",
      "flow-platform",
      "flow-product-name",
      "flow-product",
      "flow-account",
      "flow-accountdata",
      "flow-customer-reconciliation",
      "flow-statements",
      "flow-invoice",
      "contract-contract-customer",
      "contract-contract-channel",
    ]
  },
  mutations: {
    SET_COLLAPSE(state, value) {
      state.COLLAPSE = value;
    },
    SET_KEEP_ALIVE_ROUTER(state, value) {
      state.KEEP_ALIVE_ROUTER = value;
    }
  }
});